<template>
	<el-dialog
		:title="$t('agv.operationLog')"
		v-model="visible"
		width="1300"
		draggable
		:close-on-click-modal="false"
		style="font-size: large"
	>
		<el-table
			:data="tableList"
			border
            height="100%"
			style="width: 100%; height: 100%"
			:cell-style="{ textAlign: 'center' }"
			:header-cell-style="{ textAlign: 'center' ,height:'70px'}"
		>
			<el-table-column :label="$t('agv.serialNumber')" width="80" prop="id" fixed> </el-table-column>
			<el-table-column :label="$t('agv.ourSystem')" prop="taskCode" width="140"> </el-table-column>
			<el-table-column :label="$t('agv.rcsSystem')" prop="robotTaskCode" width="150">
			</el-table-column>
			<el-table-column :label="$t('agv.taskType')" prop="taskBusinessType" width="180">
			</el-table-column>
			<el-table-column :label="$t('agv.previousStartLine')" prop="firstStartLineCode" width="140">
			</el-table-column> 
			<el-table-column :label="$t('agv.previousStartPoint')" prop="firstEndLocationCode" width="140">
			</el-table-column>
			<el-table-column :label="$t('agv.previousEndLine')" prop="firstEndLineCode" width="140">
			</el-table-column>
			<el-table-column :label="$t('agv.previousEndPoint')" prop="firstStartLocationCode" width="140">
			</el-table-column>
			<el-table-column :label="$t('agv.operationType')" prop="operation" width="140">
			</el-table-column>
			<el-table-column :label="$t('agv.type')" prop="type" width="120"> </el-table-column>
			<el-table-column :label="$t('agv.creator')" prop="createUserName" width="120"> </el-table-column>
			<el-table-column :label="$t('agv.creationTime')" prop="createTime" width="160"> </el-table-column>
		</el-table>
		<template #footer>
			<div class="dialog-footer">
				<el-button type="info" @click="handleCancelClick" size="large">{{ $t('agv.close') }}</el-button>
			</div>
		</template>
	</el-dialog>
</template>

<script setup lang="ts">
import { i18n } from '/@/i18n';
import { getTaskLogByTaskCode } from '/@/api/platform/mes/agv';
// 定义变量内容
const visible = ref<boolean>(false);
const tableList = ref([]); //表格数据

// 关闭弹框
const handleCancelClick = () => {
	tableList.value = [];
	visible.value = false;
};
// 打开弹框
const openLogDialog = (index) => {
	visible.value = true;
	getTaskLogByTaskCode({ taskCode: index.taskCode, lang: i18n.global.locale.value }).then((res) => {
		tableList.value = res.result;
		tableList.value.map((item, index) => {
			item.id = index + 1;
		});
	});
};
// 暴露变量
defineExpose({
	openLogDialog,
});
</script>
<style scoped lang="scss">
</style>
